package datensaetze;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

import datensaetze.Feld;

public class FieldWithRepetition extends Feld {

	public FieldWithRepetition() {
		super();
	}

	public FieldWithRepetition(List<LineOfSubfields> fields) {
		super();
		this.fields = fields;
	}

	protected List<LineOfSubfields> fields = new ArrayList<LineOfSubfields>();

	public List<LineOfSubfields> getFields() {
		return Collections.unmodifiableList(fields);
	}

	public/*??*/void addField(LineOfSubfields field) {
		if (field == null)
			throw new IllegalArgumentException(
					"Darf kein null-Feld hinzufügen");
		fields.add(field);
	}

	@Override
	public String getAN() {
		String s = "";
		for (Iterator<LineOfSubfields> iterator = fields.iterator(); iterator
				.hasNext();) {
			LineOfSubfields field = iterator.next();
			s += field.getAN();
			if (iterator.hasNext())
				s += "\n";
		}
		return s;
	}

	@Override
	public String strukturiert() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean contains(CharSequence cs) {
		// TODO Auto-generated method stub
		return false;
	}

}
